home *** CD-ROM | disk | FTP | other *** search
/ Programming Sound Cards / Programming Sound Cards.iso / sound_56 / volume.asm < prev   
Assembly Source File  |  1995-01-01  |  3KB  |  64 lines

  1. model large,pascal
  2.  
  3. .DATA
  4. EXTRN Signeddata : BYTE
  5. EXTRN Volumetableptr : DWORD
  6. ENDS
  7.  
  8. .CODE
  9. .386
  10. PUBLIC calcVolumeTable
  11.  
  12. calcVolumetable PROC NEAR
  13.                 cmp      [signeddata],0
  14.                 je       calcunsign
  15. calcsign:       push    bp
  16.                 push    ds
  17.                 lds     si,volumetableptr     ; ds:si pointer to volumetable
  18.                 xor     di,di                 ; volume number 0..64
  19. mainloop1:      mov     cx,0                  ; sample -128..+127
  20. shortloop1:     mov     ax,di                 ; ax = current volume number
  21.                 movsx   dx,cl                 ; dx = current sample -128..127
  22.                 imul    dx
  23.                 sar     ax,6                  ; ax = sample * volume /64
  24. ok1:            mov     ds:[si],ax            ; write into table
  25.                 add     si,2                  ; next position
  26.                 inc     cx                    ; next sample
  27.                 cmp     cx,256                ; check if all done with this volume
  28.                 jne     shortloop1
  29.                 inc     di                    ; next volume
  30.                 cmp     di,65                 ; check if all volumes done
  31.                 jne     mainloop1     ; <- 65 mal wiederholen
  32.                 pop     ds
  33.                 pop     bp
  34.                 RET
  35.  
  36. ; I dounno if the following thing does work - could't test it yet :(
  37. ; ----------
  38. calcunsign:
  39. ; ----------
  40.                 push    bp
  41.                 push    ds
  42.                 lds     si,volumetableptr     ; ds:si pointer to volumetable
  43.                 xor     di,di                 ; volume number 0..64
  44. mainloop2:      mov     cx,0                  ; sample 0..255
  45. shortloop2:     mov     ax,di                 ; ax = current volume number
  46.                 mov     dx,cx
  47.                 sub     dx,128
  48.                 imul    dx
  49.                 sar     ax,6                  ; ax = sample * volume /64
  50. ok2:            mov     ds:[si],ax            ; write into table
  51.                 add     si,2                  ; next position
  52.                 inc     cx                    ; next sample
  53.                 cmp     cx,256                ; check if all done with this volume
  54.                 jne     shortloop2
  55.                 inc     di                    ; next volume
  56.                 cmp     di,65                 ; check if all volumes done
  57.                 jne     mainloop2     ; <- 65 mal wiederholen
  58.                 pop     ds
  59.                 pop     bp
  60.                 ret
  61. calcVolumetable ENDP
  62.  
  63. ENDS
  64. END